<?php 
class LoginModel extends Model{
	public $table='user';

	public function login(){
		$uname=Q('post.uname');
		$password=Q('post.password');
		if(empty($uname)){
			$this->error='帐号不能为空';
			return false;
		}
		if(empty($password)){
			$this->error='密码不能为空';
			return false;
		}

		$user=$this->where("uname='$uname'")->find();
		if(!$user){
			$this->error='用户不存在';
			return false;
		}
		unset($user['password']);
		$_SESSION['user']=$user;
		// p($_SESSION);exit;
		return true;
	}
}

?>